package com.yan.test5;

import com.yan.test5.domain.Apple;
import com.yan.test5.domain.Work;
import com.yan.test5.inter.CompareAble;

public class Test5 {
    public static void main(String[] args) {
        Work work1 = new Work();
        Work work2 = new Work();
        Apple apple1 = new Apple(5 , "青色");
        Apple apple2 = new Apple(3 , "红色");
        work1.pickApple(new CompareAble() {
            @Override
            public void compare(Apple a1, Apple a2) {
                if(a1.getSize() > a2.getSize()){
                    System.out.println(a1);
                }else{
                    System.out.println(a2);
                }
            }
        } , apple1 , apple2);

        work2.pickApple(new CompareAble() {
            @Override
            public void compare(Apple a1, Apple a2) {
                if("红色".equals(a1.getColor())){
                    System.out.println(a1);
                }
                if("红色".equals(a2.getColor())){
                    System.out.println(a2);
                }
            }
        } , apple1 , apple2);
    }
}
